package iscript.uiFramework.util.color
{
	
	public class RGB
	{
		
		private var color:uint;
		private var red:int;
		private var green:int;
		private var blue:int;
		
		public function RGB(r:Number = 0, g:Number = 0, b:Number = 0)
		{
			Red = r;
			Green = g;
			Blue = b;
		}
		
 
		public function get Red():int
		{
			return color >> 16;
		}
		
		public function get Green():int
		{
			return (color >> 8) & 0xFF;
		}
		
		public function get Blue():int
		{
			return color & 0x00FF;
		}
		
 
		public function set Red(Value:int):void
		{
			red = (Value > 255) ? 255 : ((Value < 0) ? 0 : Value);
			color = getHex(red, green, blue);
		}
		
		public function set Green(Value:int):void
		{
			green = (Value > 255) ? 255 : ((Value < 0) ? 0 : Value);
			color = getHex(red, green, blue);
		}
		
		public function set Blue(Value:int):void
		{
			blue = (Value > 255) ? 255 : ((Value < 0) ? 0 : Value);
			color = getHex(red, green, blue);
		}
		
	 
		public function get Hex():uint
		{
			return color;
		}
		
		public function set Hex(Value:uint):void
		{
			color = Value;
		}
		
 
		public static function getHex(r:int, g:int, b:int):uint
		{
			return (r << 16) | (g << 8) | b;
		}
	
	}

